import {
	createRouter,
	createWebHistory
} from 'vue-router'


const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes: [
		//默认请求/，重定向到/login
		{
			path: '/',
			redirect: '/login'
		},

		{
			path: '/login',
			name: 'login',
			component: () => import('@/views/Login.vue')
		},

		{
			path: '/index',
			name: 'index',
			component: () => import('@/views/Index.vue'),
			redirect: '/welcome',
			children: [{
					path: '/welcome',
					name: 'welcome',
					component: () => import('@/views/Welcome.vue')
				},
				{
					path: '/user',
					name: 'user',
					component: () => import('@/views/system/User.vue')
				},
				{
					path: '/role',
					name: 'role',
					component: () => import('@/views/system/Role.vue')
				},
				{
					path: '/menu',
					name: 'menu',
					component: () => import('@/views/system/Menu.vue')
				},
				{
					path: '/company',
					name: 'company',
					component: () => import('@/views/system/Company.vue')
				},
				{
					path: '/sort',
					name: 'sort',
					component: () => import('@/views/course/Sort.vue')
				},
				{
					path: '/courses',
					name: 'courses',
					component: () => import('@/views/course/Courses.vue')
				},
				{
					path: '/video',
					name: 'video',
					component: () => import('@/views/course/Video.vue')
				},
				{
					path: '/appraise',
					name: 'appraise',
					component: () => import('@/views/course/Appraise.vue')
				},
				{
					path: '/orders',
					name: 'orders',
					component: () => import('@/views/course/Orders.vue')
				},
				{
					path: '/consultants',
					name: 'consultants',
					component: () => import('@/views/consultants/Consultants.vue')
				},
				{
					path: '/level',
					name: 'level',
					component: () => import('@/views/consultants/Level.vue')
				},
				{
					path: '/field',
					name: 'field',
					component: () => import('@/views/consultants/Field.vue')
				},
				{
					path: '/toll',
					name: 'toll',
					component: () => import('@/views/consultants/Toll.vue')
				},
				{
					path: '/standard',
					name: 'standard',
					component: () => import('@/views/consultants/Standard.vue')
				},
				{
					path: '/message',
					name: 'message',
					component: () => import('@/views/consultants/Message.vue')
				},
				{
					path: '/evaluation',
					name: 'evaluation',
					component: () => import('@/views/consultants/Evaluation.vue')
				},
				{
					path: '/consultantorders',
					name: 'consultantorders',
					component: () => import('@/views/consultants/ConsultantOrders.vue')
				},
				{
					path: '/contentsort',
					name: 'contentsort',
					component: () => import('@/views/content/ContentSort.vue')
				},
				{
					path: '/essay',
					name: 'essay',
					component: () => import('@/views/content/Essay.vue')
				},

				{
					path: '/psykno',
					name: 'psykno',
					component: () => import('@/views/content/Psykno.vue')
				},

				{
					path: '/fmsort',
					name: 'fmsort',
					component: () => import('@/views/content/FMSort.vue')
				},
				{
					path: '/fmmanage',
					name: 'fmmanage',
					component: () => import('@/views/content/FMManage.vue')
				},
				{
					path: '/welfare',
					name: 'welfare',
					component: () => import('@/views/content/Welfare.vue')
				},
			
				{
					path: '/assessment',
					name: 'assessment',
					component: () => import('@/views/evaluation/Assessment.vue')
				},
				{
					path: '/assessmentsort',
					name: 'assessmentsort',
					component: () => import('@/views/evaluation/AssessmentSort.vue')
				},
				{
					path:'/questionBank',
					name:'/questionBank',
					component:() => import('@/views/evaluation/QuestionBankManagement.vue')
				},
				{
					path:'/questionResult',
					name:'/questionResult',
					component:() => import('@/views/evaluation/QuestionResult.vue')
				},
				{
					path: '/problem',
					name: 'problem',
					component: () => import('@/views/answering/Problem.vue')
				},
				{
					path: '/reply',
					name: 'reply',
					component: () => import('@/views/answering/Reply.vue')
				},
				{
					path: '/booking',
					name: 'booking',
					component: () => import('@/views/booking/Booking.vue')
				},
				{
					path: '/announcement',
					name: 'announcement',
					component: () => import('@/views/announcement/Announcement.vue')
				},
				{
					path: '/integral',
					name: 'integral',
					component: () => import('@/views/integral/Integral.vue')
				},
			]
		}
	],
})

//前置路由守卫：每次路由跳转，都要执行beforeEach里面的函数

/* 
	to：即将进入的目标
	from：当前导航正要离开的路由
	next：放行函数
 */
/* router.beforeEach((to, from, next) => {
	//只有登录界面，无需登录即可访问，其他页面都需要登录访问(如果没有登录，则跳转到登录界面)
	if (to.path == '/login') {
		return next()
	}

	//判断是否登录
	const loginUser = sessionStorage.getItem('loginUser')


	if (!loginUser) {
		return next('/login')
	} else {
		return next()
	}
}) */


export default router